import React, { useEffect } from 'react';
import ButtonNav from '@/components/ButtonNav';
// import HeaderNav from '@/components/HeaderNav';
import { Location, Dispatch } from 'umi';
import { connect } from 'dva';
import styles from './BasicLayout.less';

interface BasicLayoutProps {
  location: Location;
  dispatch: Dispatch;
  user: any;
}

const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
  const { children, location, dispatch, user } = props;

  useEffect(() => {
    // 获取用户基本信息
    if (dispatch) {
      dispatch({
        type: 'user/fetchCurrentUser',
      });
    }
  }, []);

  // console.log('123props:', props);
  return (
    <div className={styles.main}>
      {/*<HeaderNav pathName={location.pathname}></HeaderNav>*/}
      <article>{children}</article>
      <ButtonNav pathName={location.pathname}></ButtonNav>
    </div>
  );
};

// @ts-ignore
export default connect(({ user }) => ({ user }))(BasicLayout);
